package com.xspace.android.xafcommon.base;

import android.content.Context;
import android.view.View;

/**
 * Created by Wubj on 2016/3/25.
 */
public abstract class BaseHolder<T> {

    protected View holderView;
    protected Context mHolderContext;

    /**
     * 初始化holderView并设置了tag
     */
    public BaseHolder() {
        //1.初始化holderView
        holderView = initHolderView();
        //2.设置tag
        holderView.setTag(this);
    }

    /**
     * 可以传入Context,如果使用的不是内部类的形式创建的ViewHolder则使用该构造方法
     *
     * @param mContext
     */
    public BaseHolder(Context mContext) {
        this.mHolderContext = mContext;
        //1.初始化holderView
        holderView = initHolderView();
        //2.设置tag
        holderView.setTag(this);
    }

    /**
     * 获取holderView
     *
     * @return holderView
     */
    public View getHolderView() {
        return holderView;
    }

    /**
     * 初始化holderView
     *
     * @return 返回的值将赋值给holderView
     */
    protected abstract View initHolderView();

    /**
     * 绑定数据
     */
    public abstract void bindData(T info, int position);

}
